import { createBrowserRouter, NavLink } from 'react-router-dom'

import { ErrorBlock } from 'antd-mobile'

const router = createBrowserRouter([
    {
        path: '/',
        async lazy() {
            const { default: App } = await import('../App')
            return {
                element: <App></App>,
            }
        },
        children: [
            {
                index: true
            },
            {
                path: 'home',

                async lazy() {
                    const { default: Home } = await import('../pages/home')
                    return {
                        element: <Home></Home>,
                    }
                }
            },
            {
                path: 'list',

                async lazy() {
                    const { default: List } = await import('../pages/list')
                    return {
                        element: <List></List>,
                    }
                }
            },
            {
                path: 'chart',

                async lazy() {
                    const { default: Chart } = await import('../pages/chart')
                    return {
                        element: <Chart></Chart>,
                    }
                }
            },
            {
                path: 'my',

                async lazy() {
                    const { default: My } = await import('../pages/my')
                    return {
                        element: <My></My>,
                    }
                }
            },
            {
                path:'*',
               element:<ErrorBlock fullPage description={<NavLink to={'/'}>去首页</NavLink>}/>
            //    路由组件中实现404路由
            }
        ]
    }
])
export default router